package com.luck.rabbit;

import com.alibaba.fastjson.JSON;
import com.luck.email.EmailInfo;
import com.luck.email.MailService;
import com.luck.model.po.Users;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * 发送email消息监听
 * Created by Hua wb on 2018/12/11.
 */
/*@Component
@EnableRabbit
@Configuration
@RabbitListener(queues = RabbitConfig.QUEUE_EMAIL)*/
public class RabbitListeningEmail {

    @Autowired
    private MailService mailService;
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @RabbitHandler
    public void process(String content) {
        EmailInfo emailInfo = JSON.parseObject(content, EmailInfo.class);
        mailService.sendMail(emailInfo);
    }

}

